import java.io.BufferedInputStream;
import java.io.FileInputStream;
import javazoom.jl.player.Player;

public class SoundPlayer 
{
//    private String filename;
    private Player player; 

    // constructor that takes the name of an MP3 file
    public SoundPlayer() 
    {
//        this.filename = filename;
    }

    // play the MP3 file to the sound card
    public void play(String filename) 
    {
        try 
        {
            FileInputStream fis = new FileInputStream(filename);
            BufferedInputStream bis = new BufferedInputStream(fis);
            player = new Player(bis);
            try 
            { 
            	player.play();
        		Thread.sleep(1);
            }
            catch (Exception e) 
            {
            	System.out.println((e)); 
            }
        }
        catch (Exception e) {
            System.out.println("Problem playing file " + filename);
            System.out.println((e));
        }
    }

    public void close() 
    { 
    	if (player != null) player.close(); 
    }
}